<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="com.bionic.banking.logic.controller.BankTransactionController"%>
<%@page import="com.bionic.banking.core.entity.BankTransaction" %>
<%@page language="java"%>
<form method="post">
    <table border="3">
        <h3> Transaction details </h3>
        <jsp:useBean id="domainHelperBean" class="com.bionic.banking.logic.DomainUtil" />
        <jsp:useBean id="transactionBean" 
                     class="com.bionic.banking.logic.controller.BankTransactionController" />   
        <jsp:useBean id="bankTransactionsTypeBean" 
                     class="com.bionic.banking.logic.controller.BankTransactionTypeController" /> 
        <input id="id" name="id" value="${param.id}" type="hidden" />
        <c:set var="trans" value="${transactionBean.getDetails(param.id)}" />
        <c:set var="transType" value="${bankTransactionsTypeBean.getDetails(trans.txTypeId)}" />
        <tr>
            <td>Operation type</td>
            <td>              
                <input id = "txType" name="txType"  value="${transType}" readonly="true" type="text" />
            </td>
            <td>Description</td>
            <td>
                <input id = "description" name="description" value="${trans.description}"/>
            </td>
        </tr>
        <tr>
            <td>From account</td>
            <td><input  id = "accountId" name="accountId" value="${trans.accountId}" 
                readonly="true" required="true"/>
            </td>             
            <td>Amount</td>
            <td><fmt:formatNumber type="currency" pattern="####,###.##" 
                              value="${trans.amount}" var="fmtAmount" />                
                <label id = "currencyId" name="currencyId">
                    ${fmtAmount} ${domainHelperBean.getCurrencyByCode(trans.currencyId)} 
                </label>
            </td>
        </tr>  
        <tr>
            <td>Executed on</td>
            <td><input type="datetime" readonly="true" value="${trans.timeStamp}" 
                       id = "timeStamp" name="timeStamp" />
            </td> 
            <td style="visibility:${transType.getName().equals("TransferFunds") ?'visible':'hidden' }">
                To account:</td>
            <td style="visibility:${transType.getName().equals("TransferFunds")?'visible':'hidden' }">
                <input  id = "targetAccountId" name="targetAccountId" 
                        value="${trans.targetAccountId}" 
                readonly="true" />
            </td>          
        </tr>
    </table>
    <br/>
    <a href="Controller?command=viewTransactionsList"><strong>Go to List</strong></a>    
</form>